package com.example.administrator.managestake.activity;

import android.app.Application;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.example.administrator.managestake.gen.DaoMaster;
import com.example.administrator.managestake.gen.DaoSession;

/**
 * Created by Administrator on 2018/4/12 0012.
 */

public class BaseApplication extends Application{
    private static DaoSession sDaoSession;
    public  static Context sContext;

    @Override
    public void onCreate() {
        super.onCreate();
        SDKInitializer.initialize(this);
        SDKInitializer.setCoordType(CoordType.BD09LL);
        sContext = this;
        //配置数据库
        setupDatabase();
    }

    /**
     * 配置数据库
     */
    private void setupDatabase() {
      //创建数据库 location.db
        DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this,"locaton.db",null);
        //获取可写数据库
        SQLiteDatabase db = helper.getWritableDatabase();
        //获取数据库对象
        DaoMaster daoMaster = new DaoMaster(db);
        //获取Dao对象管理者
        sDaoSession = daoMaster.newSession();
    }
    public static DaoSession getDaoInstant(){
        return sDaoSession;
    }
}































